from StartGroup.models import Group
from groupAlbum.models import GroupAlbum
from django import forms
import datetime
from django.contrib.admin.widgets import AdminFileWidget

attrs_dict = { 'class': 'required' }
    
class AlbumUploadForm(forms.Form):
    
    zip_file = forms.FileField(label='Image File (.zip)', required=True, widget = AdminFileWidget())
        
    title = forms.CharField(max_length=75, required=False, label='Title:',
                                 widget=forms.Textarea(attrs={'size':'75', 'cols':'75', 'rows':'1'}))
    caption = forms.CharField(max_length=500, required=False, label='Caption:',
                                 widget=forms.Textarea(attrs={'size':'500', 'cols':'100', 'rows':'5'}))
    description = forms.CharField(max_length=1000, required=False, label='Description:',
                                 widget=forms.Textarea(attrs={'size':'100', 'cols':'100', 'rows':'10'}))
    
    def save(self, group_web_addr):
        group_info = Group.objects.get(group_web_address=group_web_addr)
        album = GroupAlbum(group = group_info,
                            title=self.cleaned_data['title'],
                            caption=self.cleaned_data['caption'],
                            description=self.cleaned_data['description'],
                            zip_file=self.cleaned_data['zip_file'],
                           )
        album.save()
        return album 